package com.mall.service.homepage.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mall.commons.common.CommonPage;
import com.mall.model.domain.SmsHomeBrand;
import com.mall.service.homepage.mapper.BrandMapper;
import com.mall.service.homepage.service.BrandService;
import org.springframework.stereotype.Service;

@Service
public class BrandServiceImpl extends ServiceImpl<BrandMapper, SmsHomeBrand> implements BrandService {
    @Override
    public CommonPage<SmsHomeBrand> findByPage(Integer pageNum, Integer pageSize, String brandName, Integer recommendStatus) {
        Page<SmsHomeBrand> page = new Page<>(pageNum, pageSize);
        LambdaQueryWrapper<SmsHomeBrand> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(brandName!=null,SmsHomeBrand::getBrandName,brandName);
        queryWrapper.like(recommendStatus!=null,SmsHomeBrand::getRecommendStatus,recommendStatus);
        this.page(page,queryWrapper);

        CommonPage <SmsHomeBrand> commonPage= CommonPage.getPage(page);

        return commonPage;
    }
}
